<div>
Description : <?=$PERMISSION['description']?>
<br>
</div>
<table width="100%" id="table_mainlist_{page}">
	<tr id="table_header_{page}">
	<?php
		for($x=0;$x<count($fields[DATA]);$x++){ 
			echo "<th  width=15%>".$fields[DATA][$x][LABEL]."</th>";
		}
	 ?>
	 <td align="center">Action</td>
 	</tr>
				<?php
					 $totalColumn = count($fields[DATA]);
					 forEach($record as $rec){ ?>
					 <tr id="tr_main_{page}_details_<?=$rec['id']?>">
					 <?php
					 	for($x=0;$x<count($fields[DATA]);$x++)
				     	 	echo "<td>" . $rec[ $fields[DATA][$x][FIELDS] ] . "</td>";
				     ?>
				     <td  align="center">
					     <?php if($PERMISSION[CAN_VIEW]): $totalColumn++;?>
						 	[<a onclick="return loadbyaction('{URL}/{page}/view/' , '{page}' , '<?=$rec['id'];?>');">view</a>]
						 <?php endif;?>
						 <?php if($PERMISSION[CAN_EDIT]): $totalColumn++;?>
						 	[<a onclick="return loadbyaction('{URL}/{page}/edit/' , '{page}' , '<?=$rec['id'];?>');">edit</a>]
						 <?php endif;?>
						 <?php if($PERMISSION[CAN_DELETE]): $totalColumn++;?>
						 	[<a onclick="return deleteRecord('{URL}/{page}/ajaxdelete/<?=$rec['id']?>' , 'tr_main_{page}_details_<?=$rec['id']?>' , '{page}' , '<?=$rec['id']?>')">delete</a>]
						 <?php endif;?>
					 </td>
					</tr>
					<tr id="tr_{page}_<?=$rec['id']?>">
						<td colspan="<?=$totalColumn?>">
							<div id="div_{page}_<?=$rec['id']?>"></div>
						</td>
					</tr>
					<?php 
					}
					 ?>
					 <?php //if($action != "ajax"):?>
					<tr id = "tr_{page}_main_details_add">
				 		<td colspan="<?=$totalColumn?>">
								[<a onclick="return loadbyaction('{URL}/{page}/add/' , '{page}' , 'add');">ADD</a>]
						</td>
				 	</tr>
				 	<tr id = "tr_{page}_add">
				 		<td colspan="<?=$totalColumn?>">
								<div id="div_{page}_add"></div>
						</td>
				 	</tr>
				 	<?php //endif;?>
</table>